/**
 * Created by Fanjiang Huang on 2016/7/7.
 */

$(function(){

    //轮播广告
    var bannerSwiper = new Swiper('.banner .swiper-container', {
        pagination: '.swiper-pagination',
        paginationClickable: true,
        centeredSlides: true,
        autoplay: 2500,
        autoplayDisableOnInteraction: false,
        loop: true
    });

    //菜单
    var menuSwiper = new Swiper('.menu .swiper-container', {
        pagination: '.swiper-pagination',
        paginationClickable: true,
        centeredSlides: true,
        autoplayDisableOnInteraction: false
    });

    //限制首页轮播图尺寸
    bannerSize();
    imgSize($('.item-img'));

    //双广告尺寸
    bannerDoubleSize($('.banner-samll li'));
});

$(window).resize(function () {
    bannerSize();
    bannerDoubleSize($('.banner-samll li'));
    imgSize($('.item-img'));
});

function imgSize (obj) {
    obj.each(function(){
        var imgWidth = $(this).width();
        $(this).height(imgWidth/1.5);
    });
};

function bannerSize () {
    var imgWidth = $(window).width();
    var imgHeight = imgWidth * (350 / 750);
    $('.banner .swiper-container').height(imgHeight);
}

function bannerDoubleSize (obj) {
    var imgWidth = $(window).width() / 2;
    var imgHeight = imgWidth * (200 / 375);
    obj.height(imgHeight);
}